<div class="md-modal md-effect-2" id="modal-2">
    <div class="md-content">
        <div class="modal-header">
            <button class="md-close close" ng-show="editStatus!=1">&times;</button>
            <button class="close" ng-click="cancelEdit()" ng-show="editStatus==1">&times;</button>
            <h4 class="modal-title">批量上传从业人员</h4>
        </div>
        <div class="modal-body">
            <form role="form">
                <div class="form-group">
                    <label>上传文件</label>
                    <form action="" enctype="multipart/form-data" method="post">
                        <input class="form-control" type="file" id='upfile' name="upfile"/>
                        <input class="btn btn-primary" id="uploadbutton" type="button" value="上传"/>
                    </form>
                </div>
                <div class="form-group">
                    <label>文件路径</label>
                    <input class="form-control" type="text" value="" id="filepath">
                </div>
            </form>
        </div>
        <div class="modal-footer">
            <!--<label  style="color: red;" >*文件后缀为.xlsx</label>-->
            <button type="button" class="btn btn-primary" ng-show="editStatus!=1" ng-click="import()">导入</button>
        </div>
    </div>
</div>

<div class="row">
    <div class="col-lg-12">
        <ol class="breadcrumb">
            <li><a><i class="fa fa-home mrg-r-sm"></i>首页</a></li>
            <li class="active"><span>服务人员列表</span></li>
        </ol>
        <div class="clearfix">
            <div class="filter-block pull-left">
                <!--搜索框 Start1-->
                <div class="form-group pull-left">
                    <input type="text" class="form-control" ng-model="search.name" placeholder="请输入姓名">
                </div>
                <div class="form-group pull-left">
                    <input type="text" class="form-control" ng-model="search.identify" placeholder="请输入身份证">
                </div>
                <div class="form-group pull-left">
                    <input type="text" class="form-control" ng-model="search.nativePlace" placeholder="请输入籍贯">
                </div>
                <div class="form-group pull-left">
                    <input type="text" class="form-control" ng-model="search.address" placeholder="请输入住址">
                </div>
                <div class="form-group pull-left">
                    <select class="form-control" ng-model="search.sex">
                        <option value="">请选择性别</option>
                        <option value="男">男</option>
                        <option value="女">女</option>
                    </select>
                </div>
                <div class="form-group pull-left">
                    <select class="form-control" ng-model="search.from">
                        <option value="">请选择来源</option>
                        <option>企业</option>
                        <option>广场前台登记</option>
                    </select>
                </div>
                <div class="form-group pull-left">
                    <input type="text" class="form-control" ng-model="search.telephone" placeholder="请输入联系电话">
                </div>
                <div class="form-group pull-left">
                    <select class="form-control" ng-model="search.serviceType1"
                            ng-change="getserviceType2(search.serviceType1.code)"
                            ng-options=" service1 as service1.title for service1 in serviceList1">
                        <option value="">请选择服务项目</option>
                    </select>
                </div>
                <div class="form-group pull-left">
                    <select class="form-control" ng-model="search.serviceType2"
                            ng-change="getserviceType3(search.serviceType2.code)"
                            ng-options=" service2 as service2.title for service2 in serviceList2">
                        <option value="">请选择服务项目</option>
                    </select>
                </div>
                <div class="form-group pull-left">
                    <select class="form-control" ng-model="search.serviceType3"
                            ng-options=" service3 as service3.title for service3 in serviceList3">
                        <option value="">请选择服务项目</option>
                    </select>
                </div>
                <div class="form-group pull-left">
                    <select class="form-control" ng-model="search.cers"
                            ng-options="c.name as c.name for c in cerslist">
                        <option value="">请选择证书</option>
                    </select>
                </div>
                <div class="form-group pull-left">
                    <select class="form-control" ng-model="search.technique"
                            ng-options="t.name as t.name for t in techniquelist">
                        <option value="">请选择技能</option>
                    </select>
                </div>
                <div class="form-group pull-left">
                    <select class="form-control" ng-model="search.servantstatus">
                        <option value="">请选择工作状态</option>
                        <option value="待岗">待岗</option>
                        <option value="在岗">在岗</option>
                        <option value="离职">离职</option>
                        <option value="休假">休假</option>
                    </select>
                </div>
                <div class="form-group pull-left">
                    <select ng-model="search.verifystatus" class="form-control">
                        <option value="">请选择审核状态</option>
                        <option>已通过审核</option>
                        <option>未通过审核</option>
                        <option>待审核</option>
                    </select>
                </div>
                <!--搜索框 End1-->
                <a class="btn btn-success pull-left form-group" ng-click="searchList(search)">
                    搜索
                </a>
                <a class="btn btn-primary pull-left form-group" href="#/servant/edit/0">
                    添加
                </a>
                <a class="md-trigger btn btn-primary mrg-b-lg pull-left" data-modal="modal-2">
                    批量导入
                </a>
            </div>
        </div>
    </div>
</div>

<div class="row">
    <div class="col-lg-12">
        <div class="main-box no-header clearfix">
            <div class="main-box-body clearfix">
                <div class="table-responsive">
                    <table class="table user-list table-hover">
                        <thead>
                        <tr>
                            <th style="width:200px;">
                                <span>人员</span>
                            </th>
                            <th class="text-center">
                                <span>联系电话</span>
                            </th>
                            <th class="text-center">
                                <span>现住址</span>
                            </th>
                            <th class="text-center" style="width:150px;">
                                <span>服务项目</span>
                            </th>
                            <th class="text-center">
                                <span>归属企业</span>
                            </th>
                            <th class="text-center">
                                <span>工作状态</span>
                            </th>
                            <th class="text-center" ng-if="!isCompanyAcount">
                                <span>审核状态</span>
                            </th>
                            <th class="text-center">
                                <span>操作</span>
                            </th>
                        </tr>
                        </thead>
                        <tbody>
                        <tr ng-repeat="item in list">
                            <td>
                                <img src="{{URL+item.photo}}" alt="" class="user_logo"
                                     ng-show="item.photo!=''&&item.photo!=null"/>
                                <img src="../../public/img/noimg.jpeg" class="user_logo"
                                     ng-if="item.photo==''||item.photo==null"/>
                                <a class="user-link">{{item.name}}</a>
                                <span class="user-subhead">{{item.sex}}</span>
                            </td>
                            <td class="text-center">{{item.telephone}}</td>
                            <td class="text-center">{{item.address}}</td>
                            <style>
                                .out_box{
                                    position: relative;
                                }
                                .out_box_text{
                                    max-height:35px; overflow: hidden;
                                }
                                .out_box_float{
                                    position: absolute;
                                    left: 50%;
                                    top: 20px;
                                    width: 150px;
                                    z-index: 10;
                                    background: #f5f5f5;
                                    border-radius: 5px;
                                    border: 1px solid #f8f8f8;
                                    display: none;
                                }
                                .out_box:hover .out_box_float{
                                    display: block;
                                }
                            </style>
                            <td class="text-center out_box" >
                                <div class="out_box_text" style="">
                                    <span ng-repeat="job in item.serviceType3_title track by $index">
                                      {{job}}&nbsp;
                                    </span>
                                </div>
                                <div class="out_box_float">
                                    <span ng-repeat="job in item.serviceType3_title track by $index">
                                      {{job}}&nbsp;
                                    </span>
                                </div>
                            </td>
                            <td class="text-center">
                                {{item.company_name}}
                                <span ng-if="item.isEmployed" style="color: #3498db;">[挂靠]</span>
                            </td>
                            <td class="text-center">
                                <span ng-if="item.servantstatus=='待岗'" class="label label-primary">{{item.servantstatus}}</span>
                                <span ng-if="item.servantstatus=='离职'" class="label label-default">{{item.servantstatus}}</span>
                                <span ng-if="item.servantstatus=='休假'" class="label label-warning">{{item.servantstatus}}</span>
                                <span ng-if="item.servantstatus=='在岗'" class="label label-success">{{item.servantstatus}}</span>
                            </td>
                            <td class="text-center" ng-if="!isCompanyAcount">
                                <span>{{item.verifystatus}}</span>
                            </td>
                            <td class="text-center">
                                <a href="#/servant/edit/{{item.servant_id}}" class="table-link">
                                    <span class="fa-stack">
                                        <i class="fa fa-square fa-stack-2x"></i>
                                        <i class="fa fa-pencil fa-stack-1x fa-inverse"></i>
                                    </span>
                                </a>
                                <a ng-click="delete(item)" class="table-link danger">
                                    <span class="fa-stack">
                                        <i class="fa fa-square fa-stack-2x"></i>
                                        <i class="fa fa-trash-o fa-stack-1x fa-inverse"></i>
                                    </span>
                                </a>
                                <a ng-if="!isCompanyAcount && (item.verifystatus==''||item.verifystatus=='未审核'||item.verifystatus==undefined||item.verifystatus=='待审核')" href="javascript:void(0);" ng-click="checkServant(item.servant_id,'已通过审核')" class="table-link" alt="通过审核">
                                    <span class="fa-stack">
                                        <i class="fa fa-square fa-stack-2x"></i>
                                        <i class="fa fa-check fa-stack-1x fa-inverse"></i>
                                    </span>
                                </a>
                                <a ng-if="!isCompanyAcount && (item.verifystatus==''||item.verifystatus=='未审核'||item.verifystatus==undefined||item.verifystatus=='待审核')" href="javascript:void(0);" ng-click="checkServant(item.servant_id,'未通过审核')" class="table-link danger">
                                    <span class="fa-stack">
                                        <i class="fa fa-square fa-stack-2x"></i>
                                        <i class="fa fa-ban fa-stack-1x fa-inverse"></i>
                                    </span>
                                </a>
                            </td>
                        </tr>
                        </tbody>
                    </table>
                </div>
                <ul class="pagination pull-right">
                    <li><a>总条数：{{count}}</a></li>
                    <li><a>总页数：{{totalPage}}</a></li>
                    <li><a ng-click="changePage(1)">首页</a></li>
                    <li><a ng-show="currentPage>1" ng-click="changePage(currentPage-1)"><i class="fa fa-chevron-left"></i></a></li>
                    <li ng-repeat="item in pageList" ng-click="changePage(item.number)" class="{{item.active}}"><a>{{item.number}}</a></li>
                    <li><a ng-show="currentPage<totalPage" ng-click="changePage(currentPage+1)"><i class="fa fa-chevron-right"></i></a></li>
                    <li><a ng-click="changePage(totalPage)">尾页</a></li>
                </ul>
            </div>
        </div>
    </div>
</div>

<div class="md-overlay"></div>
<script src="../default/js/modernizr.custom.js"></script>
<script src="../default/js/classie.js"></script>
<script src="../default/js/modalEffects.js"></script>
<script type="text/javascript">
    function init() {
        var overlay = document.querySelector('.md-overlay');
        [].slice.call(document.querySelectorAll('.md-trigger')).forEach(function (el, i) {
            var modal = document.querySelector('#' + el.getAttribute('data-modal')),
                    close = modal.querySelector('.md-close');

            function removeModal(hasPerspective) {
                classie.remove(modal, 'md-show');
                if (hasPerspective) {
                    classie.remove(document.documentElement, 'md-perspective');
                }
            }

            function removeModalHandler() {
                removeModal(classie.has(el, 'md-setperspective'));
            }

            el.addEventListener('click', function (ev) {
                classie.add(modal, 'md-show');
                overlay.removeEventListener('click', removeModalHandler);
                overlay.addEventListener('click', removeModalHandler);
                if (classie.has(el, 'md-setperspective')) {
                    setTimeout(function () {
                        classie.add(document.documentElement, 'md-perspective');
                    }, 25);
                }
            });
            close.addEventListener('click', function (ev) {
                ev.stopPropagation();
                removeModalHandler();
            });
            $(document).keyup(function (e) {
                if (e.keyCode == 27) {
                    e.stopPropagation();
                    removeModalHandler();
                }
            });
        });
    }
    function closeMod() {
        $(".md-close").click();
    }
    $(document).ready(function () {
        init();
    });
    $("#uploadbutton").click(function () {
        var filename = $("#upfile").val();
        var formData = new FormData($('form')[2]);
        $.ajax({
            type: "POST",
            url: WEB_URL + "/servant/servant/uploadFile?app_id=" + baas_jz.app_id + '&app_secret=' + baas_jz.app_secret,
            enctype: 'multipart/form-data',
            data: formData,
            processData: false,
            contentType: false,
            dataType: 'json',
            success: function (json) {
                if (json.status) {
                    $('#filepath').val(json.path);
                    alert(json.description);
                }
                else {
                    alert(json.description);
                }
            }
        });
    });
</script>
